package es.cazadoresmadridejos.beans.controller.budget;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import es.cazadoresmadridejos.beans.manager.budget.BudgetManager;
import es.cazadoresmadridejos.beans.manager.session.UserPreferences;
import es.cazadoresmadridejos.model.Budget;

@Controller
public class BudgetProfileController {

	@Autowired(required=false) private UserPreferences userPreferences;
	@Autowired private BudgetManager budgetManager;
	
	@RequestMapping("/budgetProfile.html")
	public ModelAndView profile(){
		
		Budget budget = budgetManager.getByReason(userPreferences.getReason().getId());
		
		ModelAndView mv = new ModelAndView();
		
		mv.addObject("budget", budget);
		
		return mv;
	}
}
